package com.hg.chapter4.controller;

import com.hg.chapter4.onverters.Man;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class MyController1 {

    @GetMapping("/hello")
    public String getUserId() {
        return "hello";
    }

    @GetMapping("/user/{id}/{str}")
    public String getUserId(@PathVariable Integer id, @PathVariable String str) {
        return "user ID " + id + " str: " + str;
    }

    @GetMapping("/error")
    public Map<String, Object> error() throws IllegalAccessException {
        throw new IllegalAccessException("hello");
    }

    @PostMapping("/man")
    public Man man(@RequestBody Man man){
        return man;
    }

}
